import type { QueryOptions } from '@/shared/types';
import { useQuery } from '@tanstack/react-query';
import { weatherService } from './weatherService';
import {GetWeatherRequest, WeatherData, weatherServiceKeys} from './domain';

export const weatherOptions = (params: GetWeatherRequest, options?: QueryOptions<WeatherData>) => ({
    queryKey: [...weatherServiceKeys.weather(), params],
    queryFn: () => weatherService.getWeather2(params),
    ...options,
});

export const useWeather = (params: GetWeatherRequest, options?: QueryOptions<WeatherData>) => {
    return useQuery(weatherOptions(params, options));
};